package com.example.news2.app;

import android.app.Application;
import android.content.Context;
import com.zhy.http.okhttp.OkHttpUtils;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import okhttp3.ConnectionSpec;
import okhttp3.OkHttpClient;


public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        //初始化网络配置
        initOkHttpClient();
    }
    private void initOkHttpClient(){
        OkHttpClient okHttpClient = new OkHttpClient.Builder().connectTimeout(10000L, TimeUnit.MILLISECONDS).
        readTimeout(10000L, TimeUnit.MILLISECONDS).connectionSpecs(Arrays.asList(
                ConnectionSpec.MODERN_TLS,
                ConnectionSpec.COMPATIBLE_TLS,
                ConnectionSpec.CLEARTEXT)).build();

        //使用自定义OkHttpClient
        OkHttpUtils.initClient(okHttpClient);
    }
    public static Context getContext() {
        return mContext;
    }

    private static Context mContext;
}
